package com.sihan.framework.etm.test;

import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.antherd.smcrypto.sm2.Sm2;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.springframework.core.io.ClassPathResource;

public class InitDb {

  private static final String URL = "jdbc:mysql://127.0.0.1:3306/tsms?characterEncoding=utf8&useSSL=false";



  private static final String USERNAME = "root";

  private static final String PASSWORD = "";

  public static void main(String[] args) throws SQLException, IOException {
    Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
    ScriptRunner scriptRunner = new ScriptRunner(connection);
    scriptRunner.setStopOnError(true);
    scriptRunner.setSendFullScript(false);
    ClassPathResource resource = new ClassPathResource("db.sql");
    scriptRunner.runScript(new InputStreamReader(resource.getInputStream()));
    connection.close();
  }
}
